package com.itown.expo.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.itown.expo.controller.base.MyBaseCommandController;
import com.itown.expo.model.Decl;

//正式提取报检单
public class FetchDeclController extends MyBaseCommandController {

	@Override
	protected ModelAndView handleInner(HttpServletRequest request,
			HttpServletResponse response, Object command)
			throws RuntimeException {
		Decl cdecl = (Decl) command;
		Map map = new HashMap();
		map.put("cdecl", cdecl);
		Decl declt = getServiceContainer().getCheckBizService()
				.findDeclByDeclNo(cdecl.getDeclNo());
		if (declt != null) {
			cdecl.setErrorInfo("该报检单已存在于本系统中");
			return new ModelAndView("FetchDecl.jsp", "map", map);
		}

		getServiceContainer().getCheckBizService().updateFetchDecl(cdecl);

		Decl decl = getServiceContainer().getCheckBizService()
				.findDeclByDeclNo(cdecl.getDeclNo());
		if (decl == null) {
			cdecl.setErrorInfo("从CIQ中不能检索到此报检号");
			return new ModelAndView("FetchDecl.jsp", "map", map);
		}

		return new ModelAndView(getSuccessView(), "map", map);
	}

}
